//
//  MyOrderListCell.m
//  digitalCurrency
//
//  Created by 小震GG on 2019/11/4.
//  Copyright © 2019 XinHuoKeJi. All rights reserved.
//

#import "MyOrderListCell.h"
@interface MyOrderListCell ()

@property (nonatomic, strong) UIView *bgView;
@property (nonatomic, strong) UIImageView *logoImage;
@property (nonatomic, strong) UILabel *nameLB;
@property (nonatomic, strong) UILabel *orderNoLB;
@property (nonatomic, strong) UILabel *contentLB;
@property (nonatomic, strong) UILabel *priceLB;
@property (nonatomic, strong) UILabel *typeLB;
@property (nonatomic, strong) UILabel *countLB;
@end

@implementation MyOrderListCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        self.backgroundColor = [UIColor clearColor];
        self.selectionStyle = NO;
        
        [self setView];
    }
    
    return self;
}

- (void)setView
{
    self.bgView = [[UIView alloc]initWithFrame:CGRectMake(25, 20, kWindowW-50, 134)];
    [self addSubview:self.bgView];
    self.bgView.backgroundColor = [UIColor whiteColor];
    self.bgView.layer.cornerRadius = 6.0;
    self.bgView.layer.shadowColor = [UIColor colorWithHEX:@"#6E6E6E"].CGColor;
    self.bgView.layer.shadowOffset = CGSizeMake(0, 0);
    self.bgView.layer.shadowOpacity = 0.21;
    
    self.logoImage = [[UIImageView alloc]initWithFrame:CGRectMake(10, 26, 97, 82)];
    [self.bgView addSubview:self.logoImage];
    self.logoImage.image = ImageName(@"k_logo");
    self.logoImage.clipsToBounds = YES;
    self.logoImage.contentMode = UIViewContentModeScaleAspectFill;
    UIBezierPath *maskPath = [UIBezierPath bezierPathWithRoundedRect:self.logoImage.bounds byRoundingCorners:UIRectCornerBottomLeft | UIRectCornerTopLeft cornerRadii:CGSizeMake(7.5, 7.5)];
    CAShapeLayer *maskLayer = [CAShapeLayer layer];
    maskLayer.frame = self.logoImage.bounds;
    maskLayer.path = maskPath.CGPath;
    self.logoImage.layer.mask = maskLayer;
    
    self.nameLB = [[UILabel alloc]init];
    [self.bgView addSubview:self.nameLB];
    [self.nameLB mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(114);
        make.right.equalTo(-80);
        make.top.equalTo(17);
    }];
    self.nameLB.textColor = tThreeColor;
    self.nameLB.font = kFontPF_Bold(12);
    
    self.contentLB = [[UILabel alloc]init];
    [self.bgView addSubview:self.contentLB];
    [self.contentLB mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.nameLB.mas_left);
        make.right.equalTo(-15);
        make.top.equalTo(self.nameLB.mas_bottom).offset(8);
    }];
    self.contentLB.textColor = tThreeColor;
    self.contentLB.font = kFont(12);
    
    self.orderNoLB = [[UILabel alloc]init];
    [self.bgView addSubview:self.orderNoLB];
    [self.orderNoLB mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.nameLB.mas_left);
        make.right.equalTo(-15);
        make.top.equalTo(self.contentLB.mas_bottom).offset(8);
    }];
    self.orderNoLB.textColor = tThreeColor;
    self.orderNoLB.font = kFont(12);
    
    self.countLB = [[UILabel alloc]init];
    [self.bgView addSubview:self.countLB];
    [self.countLB mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.nameLB.mas_left);
        make.top.equalTo(self.orderNoLB.mas_bottom).offset(8);
    }];
    self.countLB.textColor = tThreeColor;
    self.countLB.font = kFont(12);
    
    self.priceLB = [[UILabel alloc]init];
    [self.bgView addSubview:self.priceLB];
    [self.priceLB mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.nameLB.mas_left);
        make.top.equalTo(self.countLB.mas_bottom).offset(8);
    }];
    self.priceLB.textColor = tThreeColor;
    self.priceLB.font = kFont(12);
    
    self.typeLB = [[UILabel alloc]init];
    [self.bgView addSubview:self.typeLB];
    [self.typeLB mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(-15); make.centerY.equalTo(self.nameLB);
    }];
    self.typeLB.textColor = [UIColor colorWithHEX:@"#FF2341"];
    self.typeLB.font = kFont(12);
    
}

- (void)upDataModel:(NSDictionary *)model
{
    if ([[NSString stringWithFormat:@"%@",model[@"type"]] isEqualToString:@"1"]) {
        self.priceLB.text = [NSString stringWithFormat:@"%@%@USDT %@DWTT",LocalizationKey(@"合计："),[ToolUtil judgeStringForDecimalPlaces:[NSString stringWithFormat:@"%@",model[@"millUSDTPrice"]] point:4],[ToolUtil judgeStringForDecimalPlaces:[NSString stringWithFormat:@"%@",model[@"millDWTTPrice"]] point:4]];
    }
    else{
        self.priceLB.text = [NSString stringWithFormat:@"%@%@DWTT",LocalizationKey(@"合计："),[NSString stringWithFormat:@"%.4f",[[NSString stringWithFormat:@"%@",model[@"millDWTTPrice"]]floatValue] * [[NSString stringWithFormat:@"%@",model[@"millNum"]]floatValue]]];
    }
    self.nameLB.text = [NSString stringWithFormat:@"%@",model[@"millName"]];
    self.contentLB.text = [NSString stringWithFormat:@"%@%@",LocalizationKey(@"付款时间："),model[@"date"]];
    self.orderNoLB.text = [NSString stringWithFormat:@"%@%@",LocalizationKey(@"订单号："),model[@"orderNum"]];
    self.countLB.text = [NSString stringWithFormat:@"%@ %@ %@",LocalizationKey(@"共"),model[@"millNum"],LocalizationKey(@"件商品")];
    self.typeLB.text = LocalizationKey(@"已付款");
    
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
